<?php
include_once('common/header.php');	
if($AppUI->id <= 0 || !isset($_SERVER['HTTP_REFERER'])) {	
	Vfriend_Function::redirect(HOST_VFRIEND);
}
$strRefer		= isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$intUserId		= Vfriend_Function::base64D($objRequest->getParam('puserid',''));
$intType		= Vfriend_Function::base64D($objRequest->getParam('ptype',''));
$strFullname	= $objRequest->getParam('pfullname','');
$strToken		= $objRequest->getParam('ptoken','');
$strTok			= $intUserId . '_' . $AppUI->id;
$strSession		= isset($_SESSION['cancelFriend' . $strTok]) ? $_SESSION['cancelFriend' . $strTok] : '';
$intError		= 0;
if($intUserId && Vfriend_Function::isValidLink($strRefer) && $strToken != '' && $strSession != '' && $strSession == $strToken) {
	unset($_SESSION['cancelFriend' . $strTok]);
	$objURequest	= new URequest();
	switch($intType) {
		case 1:
			$intError		= $objURequest->deleteFriend($AppUI->id,$intUserId);
			if($intError == 0) {
				$strMessage	= $arrMessage[22];
				$strMessage	= str_replace('[strFullname]',$strFullname,$strMessage);
				Vfriend_Function::setMsg($strMessage);
			}else {
				$intError = 32;
			}
			break;
		case 2:
			$intError		= $objURequest->deleteCloseFriend($AppUI->id,$intUserId);
			if($intError == 0) {
				$strMessage	= $arrMessage[23];
				$strMessage	= str_replace('[strFullname]',$strFullname,$strMessage);
				Vfriend_Function::setMsg($strMessage);
			}else {
				$intError = 32;
			}
			break;
		case 3:
			$intError		= $objURequest->requestDivorce($AppUI->id,$intUserId);
			if($intError == 0) {
				$strMessage	= $arrMessage[23];
				$strMessage	= str_replace('[strFullname]',$strFullname,$strMessage);
				Vfriend_Function::setMsg($strMessage);
			}else {
				$intError = 32;
			}
			break;
			
	}
} else {
	$intError	= 31;
}
if($intError > 0) {
	$strError	= $arrError[$intError];
	Vfriend_Function::setError($strError);
}
Vfriend_Function::redirect(isset($strRefer) ? $strRefer : HOST_VFRIEND);
?>